#include "manano_common.h"

#include "mdtx-online/indicator/indicator_type_ma.h"
#include "mdtx-online/indicator/indicator_type_ma_osc.h"
namespace indi = mdtx::online::indicator;

using smosc = unary1<indi::smosc>;
using tmosc = unary1<indi::maosc<indi::tma>>;
using wmosc = unary1<indi::maosc<indi::wma>>;
using hmosc = unary1<indi::maosc<indi::hma>>;
using emosc = unary1<indi::emosc>;
using demosc = unary1<indi::maosc<indi::dema>>;
using temosc = unary1<indi::maosc<indi::tema>>;
using t3mosc = unary1<indi::maosc<indi::t3ma>>;
using ewmosc = unary1<indi::maosc<indi::ewma>>;
using zlemosc = unary1<indi::maosc<indi::zlema>>;

using vwmosc = binary1<indi::wmaosc<indi::vwma>>;
using evwmosc = binary1<indi::wmaosc<indi::evwma>>;

void bind_indi_ma_osc(py::module &m)
{
    auto mod = m.def_submodule("maosc", "Moving average oscillators");
    {
        auto v = py::class_<smosc>(mod, "sma")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &smosc::run, py::arg("x"), "Run calc")
                     .def("run", &smosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    SMA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<tmosc>(mod, "tma")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &tmosc::run, py::arg("x"), "Run calc")
                     .def("run", &tmosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    TMA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<wmosc>(mod, "wma")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &wmosc::run, py::arg("x"), "Run calc")
                     .def("run", &wmosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    WMA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<hmosc>(mod, "hma")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &hmosc::run, py::arg("x"), "Run calc")
                     .def("run", &hmosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    HMA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<emosc>(mod, "ema")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &emosc::run, py::arg("x"), "Run calc")
                     .def("run", &emosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    EMA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<demosc>(mod, "dema")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &demosc::run, py::arg("x"), "Run calc")
                     .def("run", &demosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    DEMA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<temosc>(mod, "tema")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &temosc::run, py::arg("x"), "Run calc")
                     .def("run", &temosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    TEMA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<t3mosc>(mod, "t3ma")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &t3mosc::run, py::arg("x"), "Run calc")
                     .def("run", &t3mosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    T3MA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<ewmosc>(mod, "ewma")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &ewmosc::run, py::arg("x"), "Run calc")
                     .def("run", &ewmosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    EWMA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<zlemosc>(mod, "zlema")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &zlemosc::run, py::arg("x"), "Run calc")
                     .def("run", &zlemosc::run2, py::arg("x"), "Run batch calc");
        v.doc() = R"mydoc(
                    ZLEMA oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }

    {
        auto v = py::class_<vwmosc>(mod, "vwma")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &vwmosc::run, py::arg("x"), py::arg("w"), "Run calc")
                     .def("run", &vwmosc::run2, py::arg("x"), py::arg("w"), "Run batch calc");
        v.doc() = R"mydoc(
                    VWMA (volume weighted moving average) oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
    {
        auto v = py::class_<evwmosc>(mod, "evwma")
                     .def(py::init<int, int>(), py::arg("fast_period"), py::arg("slow_period"))
                     .def("run", &evwmosc::run, py::arg("x"), py::arg("w"), "Run calc")
                     .def("run", &evwmosc::run2, py::arg("x"), py::arg("w"), "Run batch calc");
        v.doc() = R"mydoc(
                    EVWMA (elastic volume weighted moving average) oscillator
                    Args:
                        fast_period (int) : fast MA period
                        slow_period (int) : slow MA period)mydoc";
    }
}
